      SUBROUTINE OPERW ( MESSAG, WHO, REPLY )
C*
C*                  *******************************
C*                  *******************************
C*                  **                           **
C*                  **          OPERW            **
C*                  **                           **
C*                  *******************************
C*                  *******************************
C*
C*     SUBPROGRAM :
C*          OPERATOR MESSAGE/WAIT FOR REPLY
C*
C*     AUTHOR :
C*          ART RAGOSTA
C*          MS 207-5
C*          AMES RESEARCH CENTER
C*          MOFFETT FIELD, CA   94035
C*          (415) 694-5578
C*
C*     PURPOSE :
C*          TO SEND A MESSAGE TO AN OPERATOR'S CONSOLE AND WAIT FOR A
C*          REPLY.
C*
C*     INPUT ARGUMENTS :
C*          MESSAG - THE TEXT OF THE MESSAGE TO BE SENT
C*          WHO    - THE OPERATOR TO RECEIVE THE MESSAGE (EG,'CENTRAL','TAPES')
C*
C*     OUTPUT ARGUMENTS :
C*          REPLY - THE TEXT STRING ENTERED BY THE OPERATOR, OR AN ERROR
C*                   MESSAGE(FIRST WORD IS 'ERROR')
C*
C*     INTERNAL WORK AREAS :
C*          MSGBUF - THE BUFFER FOR THE MESSAGE AND COMMAND CODES
C*          OPER,IOPER - THE OPERATOR TARGET CODES IN ASCII AND BINARY
C*
C*     COMMON BLOCKS :
C*          NONE
C*
C*     FILE REFERENCES :
C*          0 - READ FROM MAILBOX
C*
C*     SUBPROGRAM REFERENCES :
C*          SYS$SNDOPR, SYS$CREMBX, SYS$DASSGN
C*
C*     ERROR PROCESSING :
C*          THE STATUS OF THE PREVIOUS SYSTEM SERVICE CALL IS CHECKED
C*          BEFORE CONTINUING.
C*
C*     TRANSPORTABILITY LIMITATIONS :
C*          HIGHLY NON-TRANSPORTABLE
C*
C*     ASSUMPTIONS AND RESTRICTIONS :
C*          NO CHECK IS PERFORMED TO SEE IF 'WHO' IS VALID
C*
C*     LANGUAGE AND COMPILER :
C*          ANSI FORTRAN 77
C*
C*     VERSION AND DATE :
C*          VERSION I.0     25-JUL-85
C*
C*     CHANGE HISTORY :
C*          25-JUL-85    INITIAL VERSION
C*
C***********************************************************************
C*
      CHARACTER *(*) MESSAG, WHO, REPLY
      CHARACTER *132 MSGBUF
      CHARACTER *2 OPERS(11), DUMMY
      INTEGER *2 IOPER(11), IDUMMY
      EQUIVALENCE (DUMMY,IDUMMY)
C
C --- OPERATOR TARGET CODES FROM SYSLIB:STARLET($OPCDEF)
C
      DATA OPERS/'CE','PR','TA','DI','DE','CA','NT','CL','SE','RE','NE'/
      DATA IOPER/ 1,   2,   4,   8,   16,  32,  64, 128, 256, 512,  64/
C
C --- TO WHOM DO WE SEND THE MESSAGE ?
C
      DO 10 I = 1,11
         IF (WHO(1:2) .EQ. OPERS(I)) GO TO 20
10       CONTINUE
      I = 1
C
20    MSGBUF(1:1) = CHAR(3)           ! REQUEST ALWAYS
      IDUMMY = IOPER(I)
      MSGBUF(2:2) = CHAR(0)
      MSGBUF(3:4) = DUMMY             ! OPERATOR TARGET CODE
      MSGBUF(5:8) = '    '
      MSGBUF(9:132) = MESSAG          ! USER'S MESSAGE
C
C --- OPEN MAILBOX FOR REPLY
C
      ISTAT = SYS$CREMBX ( ,ICHAN,,,,, 'OPERMBX' )
      IF ( ISTAT .NE. 0 ) THEN
         REPLY = 'ERROR OPENING MAILBOX'
         RETURN
      ENDIF
C
C --- SEND THE MESSAGE
C
      ISTAT = SYS$SNDOPR(MSGBUF,%VAL(ICHAN))
      IF ( ISTAT .NE. 0 ) THEN
         REPLY = 'ERROR OPENING MAILBOX'
         RETURN
      ENDIF
      OPEN (UNIT=0,NAME='OPERMBX',TYPE='OLD')
      READ(0,900,END=100,ERR=100) MSGBUF
      GO TO 200
100   REPLY = 'ERROR GETTING OPERATOR REPLY'
200   CLOSE(UNIT=0)
      ISTAT = SYS$DASSGN(%VAL(ICHAN))
      REPLY = MSGBUF(9:132)
      RETURN
900   FORMAT(A)
      END
C
C---END OPERW
C
